package FlyWeight;

import java.util.HashMap;
import java.util.Map;

public class Factory {
    private Map<Integer, Rank> pool = new HashMap<>();
    private static Factory factory = new Factory();
    private Factory() {}
    public static Factory getInstance() {
        return factory;
    }
    public synchronized Rank getRank(Customer c, Rank r) {
        if(!pool.containsKey(c.id)) {
            pool.put(c.id, r);
        }
        return pool.get(c.id);
    }
}
